<template>
    <div class="untreated">
        <datatable :curPage="curPage" :pageSize="pageSize" :options="options" :pageNum="pageNum" :tableHeader="tableHeader" @pageChange="untreatedGrid" @handClick="handClick"
        ></datatable>
    </div>
</template>

<script>
export default {
    name: 'untreated',
    data() {
        return {
            id: '',     // 需求id号
            tableData: {},
            options: [],
            curPage: 1,
            pageSize: 10,
            pageNum: 0,
			tableHeader: [
                { prop: 'id', label: '需求单号', router: '/task/detail', width: '120'},
                { prop: 'name', label: '任务名称'},
                { prop: 'description', label: '任务描述', width: '150'},
                { prop: 'relation_team', label: '涉及项目组'},
                { prop: 'main_people', label: '责任人'},
                { prop: 'code_count', label: '代码量'},
                { prop: 'suppose_start_time', label: '期望开始时间', type: "time", width: '180'},
                { prop: 'suppose_end_time', label: '期望结束时间', type: "time", width: '180'},
                { prop: 'level', label: '优先级'},
                { prop: 'product', label: '产品'},
                { prop: 'source', label: '来源'},
                { prop: 'type', label: '分类'},
                { prop: 'property', label: '产品属性'},
                { prop: 'keep_word', label: '对外承诺'},
                { prop: 'state', label: '状态', width: '80'},
                { prop: 'current_dealers', label: '当前处理者'},
                { prop: 'delay', label: '延迟天数'},
			],
        }
    },
    computed: {},
    methods: {
        untreatedGrid(num, size) {
            if(num) {
                this.curPage = num;
                this.pageSize = size;
            }
            console.log(this.tableData)
            if(!this.tableData[this.curPage]) { // tableData 中没有存储
                let user = JSON.parse(localStorage.getItem('user'));
                this.$api.getGridList(this.curPage, this.pageSize, {current_dealers: user.message}).then(res=>{
                    if(res.code === 0) {
                        let data = res.data.list;
                        this.$set(this.tableData, this.curPage, data);   // 将请求过的数据存储在 tableData 中
                        this.pageNum = res.data.size;
                        this.options = this.tableData[this.curPage];
                    }
                })
            }else { // tableData 中有存储
                this.options = this.tableData[this.curPage];
            }
        },
        handClick(id) {
            console.log('id1=' + id)
            this.id = id;
        }
    },
    mounted() {
        this.untreatedGrid();
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
.untreated {}
</style>